package com.jboost.hyk.common.constant;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.jboost.common.constant.CommonConstant;
import com.jboost.common.constant.EnumInterface;

public enum BusinessActionEnum implements EnumInterface {
    // 操作：new-新建；submit-提交；success-同意；fail-驳回；invalid-停用；expired-已过期；
    NEW("new", "新建"),
    EDIT("edit", "编辑"),
    SUBMIT("submit", "提交"),
    SUCCESS("success", "同意"),
    FAIL("fail", "驳回"),
    INVALID("invalid", "停用"),
    VALID("valid", "启用"),
    ASSIGN_MANAGER("assign_manager", "指派客户经理"),
    CHANGE_MANAGER("change_manager", "变更客户经理"),
    EXPIRED("expired", "已过期");

    BusinessActionEnum(String code, String desc) {
        this.code = code;
        this.value = desc;
        this.desc = desc;
    }

    @EnumValue
    @JsonValue    //标记响应json值
    private final String code;
    private final String value;
    private final String desc;

    public String getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }
    public static BusinessActionEnum getByCode(String code) {
        BusinessActionEnum[] enums = BusinessActionEnum.values();
        for (int i = 0; i < enums.length; i++) {
            if(enums[i].code.equals(code)){
                return enums[i];
            }
        }
        return null;
    }
    public static String getValueByCode(String code) {
        BusinessActionEnum status = BusinessActionEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getValue();
    }
    public static String getDescByCode(String code) {
        BusinessActionEnum status = BusinessActionEnum.getByCode(code);
        if(null == status){
            return CommonConstant.UNDIFIND_DEFALUT;
        }
        return status.getDesc();
    }

    @Override
    public String desc() {
        return this.desc;
    }

    @Override
    public Integer value() {
        return null;
    }

    @Override
    public String code() {
        return this.code;
    }


}
